/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2020-2023. All rights reserved.
 * Description: introduce x86_mce_custom_check for N9000 BBU multi-bit ECC error
 * Author: Lv Ying
 * Create: 2020-03-25
 */

#ifndef _LINUX_EULEROS_MCE_CUSTOM_CHECK_H
#define _LINUX_EULEROS_MCE_CUSTOM_CHECK_H

#ifdef CONFIG_EULEROS_MULTIBIT_ECC_CUSTOM_CHECK
/*
 * Custom check handler
 */
extern int (*x86_mce_custom_check)(struct mce *mce_ptr);
extern struct atomic_notifier_head x86_mce_custom_chain;

static inline void notify_mce_custom(void)
{
	atomic_notifier_call_chain(&x86_mce_custom_chain, 0, NULL);
}
static inline bool handle_x86_mce_custom_check(struct mce *m)
{
	return x86_mce_custom_check && x86_mce_custom_check(m);
}
#else /* !CONFIG_EULEROS_MULTIBIT_ECC_CUSTOM_CHECK */
static inline void notify_mce_custom(void) {}
static inline bool handle_x86_mce_custom_check(struct mce *m)
{
	return false;
}
#endif /* CONFIG_EULEROS_MULTIBIT_ECC_CUSTOM_CHECK */
#endif /* _LINUX_EULEROS_MCE_CUSTOM_CHECK_H */
